Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Required for nil.try to be available #2784

Merged
merged 1 commit into from
Feb 21, 2025
Merged

Conversation

pablobm
Copy link
Collaborator

@pablobm pablobm commented Feb 21, 2025

The spec spec/lib/fields/url_spec.rb is failing when run on its own:

$ rspec spec/lib/fields/url_spec.rb:22
Run options: include {locations: {"./spec/lib/fields/url_spec.rb" => [22]}}

Randomized with seed 23913
F

Failures:

  1) Administrate::Field::Url#truncate renders an empty string for nil
     Failure/Error: resource.try(attribute)
     
     NoMethodError:
       undefined method 'try' for nil
     # ./lib/administrate/field/base.rb:67:in 'Administrate::Field::Base#read_value'
     # ./lib/administrate/field/base.rb:44:in 'Administrate::Field::Base#initialize'
     # ./spec/lib/fields/url_spec.rb:23:in 'Class#new'
     # ./spec/lib/fields/url_spec.rb:23:in 'block (3 levels) in <top (required)>'

Finished in 0.00103 seconds (files took 0.15639 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/lib/fields/url_spec.rb:22 # Administrate::Field::Url#truncate renders an empty string for nil

Randomized with seed 23913

This is due to nil.try not being available unless Rails has been loaded. Requiring rails_helper fixes this.

@pablobm pablobm marked this pull request as ready for review February 21, 2025 11:44
@pablobm pablobm merged commit 44b9ff7 into thoughtbot:main Feb 21, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant